package huawei.widget;

import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.drawable.Drawable;
import android.os.Build.VERSION;
import android.util.AttributeSet;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import androidx.annotation.Nullable;
import o.fkr$d;
import o.fkr$e;
import o.fkr$f;
import o.fkr$g;
import o.fkr$i;
import o.fkr$j;
import o.fo;
import o.fpx;
import o.fqb;
import o.gg;

public class HwIconTextLayout extends LinearLayout {
    private Drawable ʻ;
    private boolean ˊ;
    private EditText ˋ;
    private c ˎ;
    private ImageView ˏ;
    private OnClickListener ॱ;
    private View ॱॱ;

    public interface c {
        void ˊ(ImageView imageView, boolean z);
    }

    public HwIconTextLayout(Context context) {
        this(context, null);
    }

    public HwIconTextLayout(Context context, @Nullable AttributeSet attributeSet) {
        this(context, attributeSet, fkr$d.ˏ);
    }

    public HwIconTextLayout(Context context, @Nullable AttributeSet attributeSet, int i) {
        super(fqb.ˋ(context), attributeSet, i);
        ˎ(super.getContext(), attributeSet, i);
    }

    private void ˎ(Context context, @Nullable AttributeSet attributeSet, int i) {
        TypedArray obtainStyledAttributes = context.obtainStyledAttributes(attributeSet, fkr$i.ˍ, i, fkr$g.ॱॱ);
        fpx o_fpx = fpx.values()[obtainStyledAttributes.getInt(fkr$i.ˋᐝ, 0)];
        if (o_fpx == fpx.BUBBLE) {
            inflate(context, fkr$j.ˏ, this);
        } else {
            inflate(context, fkr$j.ॱ, this);
        }
        this.ˋ = (EditText) findViewById(fkr$f.ˏ);
        this.ˏ = (ImageView) findViewById(fkr$f.ˎ);
        this.ॱॱ = (View) this.ˏ.getParent();
        CharSequence string = obtainStyledAttributes.getString(fkr$i.ˌ);
        CharSequence string2 = obtainStyledAttributes.getString(fkr$i.ˋˋ);
        this.ˋ.setHint(string);
        this.ˋ.setText(string2);
        this.ˊ = obtainStyledAttributes.getBoolean(fkr$i.ˏˏ, false);
        if (obtainStyledAttributes.hasValue(fkr$i.ˎˎ)) {
            this.ˏ.setImageDrawable(ˏ(obtainStyledAttributes.getResourceId(fkr$i.ˎˎ, 0)));
        }
        Drawable drawable = obtainStyledAttributes.getDrawable(fkr$i.ͺॱ);
        Drawable drawable2 = obtainStyledAttributes.getDrawable(fkr$i.ˑ);
        if (o_fpx != fpx.BUBBLE) {
            drawable2 = drawable;
        }
        setIconBackground(drawable2);
        ˏ();
        this.ॱॱ.setOnClickListener(new OnClickListener(this) {
            final /* synthetic */ HwIconTextLayout ˎ;

            {
                this.ˎ = r1;
            }

            public void onClick(View view) {
                if (this.ˎ.ˊ) {
                    this.ˎ.ˋ();
                    if (this.ˎ.ˎ != null) {
                        this.ˎ.ˎ.ˊ(this.ˎ.ˏ, this.ˎ.ॱ());
                    }
                }
                if (this.ˎ.ॱ != null) {
                    this.ˎ.ॱ.onClick(this.ˎ.ˏ);
                }
            }
        });
        obtainStyledAttributes.recycle();
    }

    private void ˏ() {
        if (this.ˊ) {
            this.ॱॱ.setBackground(null);
            ˋ();
            ˎ();
            return;
        }
        this.ॱॱ.setBackground(this.ʻ);
    }

    private void ˎ() {
        if (VERSION.SDK_INT >= 26) {
            this.ˋ.setAutofillHints(new String[]{"password"});
        }
    }

    private boolean ˊ() {
        int i;
        int i2;
        int i3 = 1;
        int inputType = this.ˋ.getInputType() & 4095;
        if (inputType == 129) {
            i = 1;
        } else {
            i = 0;
        }
        if (inputType == 225) {
            i2 = 1;
        } else {
            i2 = 0;
        }
        i2 |= i;
        if (inputType != 18) {
            i3 = 0;
        }
        return i3 | i2;
    }

    private boolean ॱ() {
        return (this.ˋ.getInputType() & 4095) == 145;
    }

    private void ˋ() {
        if (ॱ() || !ˊ()) {
            this.ˋ.setInputType(129);
            this.ˏ.setImageDrawable(ˏ(fkr$e.ˎ));
            return;
        }
        this.ˋ.setInputType(145);
        this.ˏ.setImageDrawable(ˏ(fkr$e.ˋ));
    }

    private Drawable ˏ(int i) {
        Drawable ˊ = fo.ˊ(getContext(), i);
        if (ˊ != null) {
            gg.ˏ(ˊ, true);
        }
        return ˊ;
    }

    public void setText(CharSequence charSequence) {
        this.ˋ.setText(charSequence);
    }

    public void setHint(CharSequence charSequence) {
        this.ˋ.setHint(charSequence);
    }

    public void setIcon(Drawable drawable) {
        this.ˏ.setImageDrawable(drawable);
    }

    public void setIconBackground(Drawable drawable) {
        this.ॱॱ.setBackground(drawable);
        this.ʻ = drawable;
    }

    public void setOnIconClickListener(OnClickListener onClickListener) {
        this.ॱ = onClickListener;
    }

    public void setOnPasswordVisibleChangedListener(c cVar) {
        this.ˎ = cVar;
        boolean z = cVar != null;
        if (this.ˊ != z) {
            this.ˊ = z;
            ˏ();
        }
    }

    public void setPasswordType(boolean z) {
        if (this.ˊ != z) {
            this.ˊ = z;
            ˏ();
        }
    }
}
